package com.cyedu.tsapp.exception;

import com.cyedu.tsapp.entity.Result;
import com.cyedu.tsapp.utils.ResultUtil;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class SysRuntimeExceptionHandler {
 
  @ExceptionHandler(TokenRuntimeException.class)
  public Result tokenRuntimeException(TokenRuntimeException e) {
    e.printStackTrace();
    return ResultUtil.defineFail(e.getCode(), e.getMsg());
  }
 
  @ExceptionHandler(Exception.class)
  public Result handlerException(Exception e){
    e.printStackTrace();
    return ResultUtil.fail(e.getMessage());
  }
}